# email_defs.py
# 
# This file is the "local definitions" part of Peter Ballard's email spam filter.
# Some of this you will need to change,
# and most of this you will want to change.
#
# Note the definitions for whitelist and blackdomains are not done here,
# but are in separate files. This is because these two lists can be quite
# long, and might even be created automatically. In these files,
# each (whitespace separated) string in the file becomes a list element,
# unless the line begins with "#" or ";"
# These files are not included in the package, because obviously I don't
# want to make my whitelist public.
#
# Version 1.0, 4-Apr-2005.
#
#Copyright (C) 2005  Peter Ballard
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
# 

#######################################
# definitions for email in and out files
#######################################
SYSMAILDIR = "/home/pballard/sysmail/"
MAILNAME = SYSMAILDIR + "pballard"

srcfilename = MAILNAME + ".raw"
storefilename = MAILNAME + ".store"
spamfilename = MAILNAME + ".spam"
hamfilename = MAILNAME + ".ham"
whamfilename = MAILNAME + ".wham"
mhamfilename = MAILNAME + ".mham"
panicfilename = MAILNAME + ".panic"

test_srcfilename = MAILNAME + ".store" # i.e. read back all the stored emails
#test_storefilename = "" # never used
test_spamfilename = "/dev/null"
# note these are written, not appended. Those parameters probably belong in here.
test_hamfilename = SYSMAILDIR + "test.ham"
test_whamfilename = SYSMAILDIR + "test.wham"
test_mhamfilename = SYSMAILDIR + "test.mham"
test_panicfilename = SYSMAILDIR + "test.panic"


#######################################
# Stuff used to detect spam
#######################################

# A few notes:
#
# "string" refers to a string
# "word" refers to a string bounded by whitespace
# "regexp" refers to a Python regular expression
# "phrase" is a set of words, separated by whitespace
# "intro" refers to the subject line plus the first 300 characters
# of the message body
#
# All text is (including email addresses) is converted to lower case.
#
# Lists of email names ("my_addresses" and "whitelist")
# may contain domain names also.

my_address = "pballard@ozemail.com.au"
my_isp_domain = "ozemail.com.au"

# you can add secondary email addresses to this list of strings
my_addresses = [my_address]

# words in the intro, or early in the body, which indicate mham
# (Mine are edited out. Add your own).
whiteintrowords = [] # a list of strings

# strings in the subject line (or early in the body) which indicate mail is mham
# (Mine are edited out. Add your own).
whiteintrostrings = [] # a list of strings

MAILLISTDIR = "/home/pballard/mail/"
whitelist = MAILLISTDIR + "whitelist.txt"
blackdomains = MAILLISTDIR + "blackdomains.txt"

# making most blackwords tricky (not just the usual suspects in the 1st and last lines)
# reduced (false) hams from 100 to 72,
# and increased time from 38 to 46 seconds for python 2.4a3
# (48 to 66 for python 2.2)
# for a corpus of 4149 messages (284 whams)
trickywords = ["xanax", "viagra", "cialis", "vicodin", "valium", "penis", "pharmacy",
               "incest", "explicit", "ejaculation", "porno", "erection", "erections",
               "orgasm", "pussy", "slut", "slutty", "sluts",
               "personals",
               "lottery",
               "insurance", "wholesale", "mastercard",
               "medication", "meds", "adipren", "prescription",
               "hydrocodone",
               "spyware",
               "diploma", "diplomas",
               "mortgage", "refinance",
               "rolex"]

# dont put mlm in tricky words, because it can be mistaken for "mim"
# which might be a valid word (e.g. "mim" is an Islamic word).
blackwords = ["elkedeseen", "mlm"]

blackphrases = ["improve your size",
                "rock hard",
                "3 inches",
                #"big dick",
                #"huge dick",
                "business offer",
                "business proposal",
                "future mailing",
                "further mailing",
                "business investment",
                "million dollars",
                "utmost confidentiality",
                "ultmost confidentiality",
                "bank transfer",
                "money transfer",
                "account details",
                "foreign accounts",
                "low price",
                "double your money",
                "money back guarantee",
                "credit card",
                "email database",
                "xp professional",
                "traders report",
                "stock dividend",
                "hot stocks",
                "active stock",
                "stock update",
                "lotto games",
                "want a watch", "cheap watch",
                "red light cameras", "speed cameras"]

blackregexps = [r"font-size:\s*[01][^0-9\.]", # tiny html font
                r"[a-z]<!.*?>[a-z]", # html comments in middle of a word
                r"http://[0-9]+\.[0-9]+\.[0-9]+\.", # numerical url
                #r"^ =\?", # subject begins with "=?" # covered in function bad_subject()
                r"pills[0-9]*\.gif"]

blackstrings = ["fuck",
                # currently non-alphanumerics go in strings only
                "auto-generated",
                # check for the string because it's often in a domain name
                "casino"]

# .zip is OK from whitelisted people, but some spammers send it
black_attachment_types = ["com", "cpl", "exe", "pif", "scr", "vbs", "bat", "zip"]

# a function to check the X-Mailer field (the string xmailer here)
# to see if it's really from me.
# Note, in contrast to everything else, the X-Mailer field has NOT
# been converted to lower case.
# I've put this in email_defs.py because it probably would vary wildly
# from user to user
def really_from_me(xmailer):
    return xmailer[:5]=="Emacs"
